package com.itheima.health.controller.mobile;

import com.itheima.health.common.MessageConst;
import com.itheima.health.pojo.dto.OrderDTO;
import com.itheima.health.pojo.entity.Order;
import com.itheima.health.pojo.entity.OrderShow;
import com.itheima.health.pojo.result.Result;
import com.itheima.health.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/mobile/order")
public class OrderController {
    @Autowired
    private OrderService orderService;


    /**
     * 体检预约
     * @param orderDTO
     * @return
     */
    @PostMapping("/submit")
    public Result submit(@RequestBody OrderDTO orderDTO){
        log.info("预约信息：{}",orderDTO);
        Order order = orderService.submit(orderDTO);
        return new Result(true, MessageConst.ORDER_SUCCESS,order);
    }

    /**
     * 根据id查询订单数据详情
     * @param id
     * @return
     */
    @GetMapping("/findById")
    public Result findOrderById(Integer id) {
        log.info("根据id查询订单数据详情");
        OrderShow order = orderService.findOrderById(id);
        return new Result(true, MessageConst.QUERY_ORDER_SUCCESS,order);
    }
}
